<div class="std_header auto_height">
    <div class="left">
        <strong><?php echo $module['title']; ?></strong>
    </div>
    <div class="right">
        <button class="gray_btn"
                onclick="window.location='<?php echo site_url('admin/cms/article/edit', true); ?>'">
            <span>Thêm mới</span></button>
        <button class="gray_btn"
                onclick="window.location='<?php echo site_url('admin/cms/article/index', true); ?>'">
            <span>Xóa lọc</span></button>
    </div>
</div>
<div id="article_management">
    <?php $this->load->view('cms/article/message'); ?>
    <div id="tab_list">
        <form action="<?php echo site_url('admin/cms/article/index', true); ?>" method="post" id="frm_article_gridview">
        <?php if (count($collection) != 0) : ?>
        <?php $paginator = $this->load->view('cms/article/paginator', null, true); echo $paginator; ?>
            <input type="hidden" name="current_page" id="current_page" value="<?php echo $current_page; ?>" />
            <div class="block">
                <table class="gridview" width="100%" cellpadding="0" cellspacing="0" border="0">
                    <thead>
                    <tr>
                        <td><input id="check_all" type="checkbox" onclick="btn_util.check_all(this.checked, '.chk_id')" /></td>
                        <td><b>ID</b></td>
                        <td><b>Ảnh</b></td>
                        <td><b>Tiêu đề</b></td>
                        <td width="100px"><b>Xuất bản</b></td>
                        <td><b>Mô tả</b></td>
                        <td><b>Thao tác</b></td>
                    </tr>
                    </thead>
                    <tbody>
                    <tr class="filters">
                        <td colspan="2">
                            <input type="text" class="small_filter" name="filters[id][value]" title="Tìm kiếm theo id bài viết" value="<?php echo $filters['id']['value']; ?>" />
                            <input type="hidden" value="range" name="filters[id][type]" />
                        </td>
                        <td colspan="2">
                            <input type="text" class="wide_filter" name="filters[title][value]" title="Tìm kiếm theo tiêu đề bài viết" value="<?php echo $filters['title']['value']; ?>" />
                            <input type="hidden" value="text" name="filters[title][type]" />
                        </td>
                        <td>
                            <select name="filters[publish][value]" id="filters_publish">
                                <option value="-1">Tất cả trạng thái</option>
                                <option value="1">Có</option>
                                <option value="0">Không</option>
                            </select>
                            <input type="hidden" value="equal" name="filters[publish][type]" />
                            <input type="hidden" value="-1" name="filters[publish][exclude]" />
                        </td>
                        <td>
                            <input title="Tìm kiếm theo mô tả bài viết" type="text" class="wide_filter" name="filters[description][value]" value="<?php echo $filters['description']['value']; ?>" />
                            <input type="hidden" value="text" name="filters[description][type]" />
                        </td>
                        <td width="200px">
                            <button class="gray_btn" type="submit">
                                <span>Lọc</span>
                            </button>
                            <button class="gray_btn" type="button" onclick="admin_cms_article.reset_filters();">
                                <span>Xóa lọc</span>
                            </button>
                        </td>
                    </tr>
                    <?php foreach ($collection as $article) : ?>
                    <tr <?php if (empty($article->publish)) :?>class="no_publish"<?php endif; ?>>
                        <input type="hidden" value="" class="edit_url"/>
                        <td width="30px" valign="top">
                            <input class="chk_id" type="checkbox" name="selected[]" value="<?php echo $article->id; ?>" />
                        </td>
                        <td width="30px" valign="top">
                            <?php echo $article->id; ?>
                        </td>
                        <td valign="top" width="60px">
                            <img width="80px" style="border: 2px solid #ccc" src="<?php echo render_src(get_field($article, 'image')); ?>" />
                        </td>
                        <td valign="top" width="400px">
                            <p><strong><a href="<?php echo cms_article_model::get_edit_url($article->id); ?>"><?php echo get_field($article, 'title'); ?></a></strong></p>
                            <p class="small_datetime"><?php echo render_date(get_field($article, 'publish_day')); ?></p>
                        </td>
                        <td valign="top">
                            <?php echo get_field($article, 'publish') == 1 ? 'Có' : 'Không'; ?>
                        </td>
                        <td valign="top" width="500px">
                            <p class="item_desc"><?php echo empty($article->description) ? '<span class="empty">Trống</span>' : $article->description; ?></p>
                        </td>
                        <td valign="top">
                            <p>
                                <a class="icon icon_edit" href="<?php echo site_url('admin/cms/article/edit/id/' . $article->id, true); ?>"></a>
                                <a class="icon icon_delete" href="<?php echo site_url('admin/cms/article/delete/id/' . $article->id, true); ?>" onclick="return confirm('Bạn muốn xóa bài viết này?')"></a></p>
                        </td>
                    </tr>
                        <?php endforeach; ?>
                    </tbody>
                    <tfoot>
                    </tfoot>
                </table>
            </div>
        <?php echo $paginator; ?>
        <?php else : ?>
        <div class="error_message corner">Không có bài viết nào</div>
        <?php endif; ?>
        </form>
    </div>
</div>
<script type="text/javascript" src="<?php echo BASE_URL; ?>js/admin/cms/article/function.js"></script>